home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993…ch: Other People's Memory / ADC Developer CD (1993-03) (''Other People's Memory'')_iso / Dev.CD Mar 93.iso / Development Platforms / Apple II / Essentials / MPW IIGS Interfaces / PIIGSIncludes / Controls.p < prev    next >
Encoding:
Text File  |  1992-02-26  |  15.1 KB  |  454 lines  |  [TEXT/MPS ]

  1. {********************************************
  2. ; File: Controls.p
  3. ;
  4. ;
  5. ; Copyright Apple Computer, Inc. 1986-91
  6. ; All Rights Reserved
  7. ;
  8. ********************************************}
  9.  
  10. UNIT CONTROLS;
  11.  
  12. INTERFACE
  13.  
  14. USES TYPES,QUICKDRAW,EVENTS;
  15.  
  16. CONST
  17. { Axis Parameters }
  18. noConstraint = $0000;  { No constraint on movement. }
  19. hAxisOnly = $0001;  { Horizontal axis only. }
  20. vAxisOnly = $0002;  { Vertical axis only. }
  21.  
  22. { CtlFlag }
  23. simpRound = $0000;  { Simple button flag }
  24. upFlag = $0001;  { Scroll bar flag.  }
  25. boldButton = $0001;  { Bold round cornered outlined button. }
  26. simpBRound = $0001;  { Simple button flag }
  27. downFlag = $0002;  { Scroll bar flag. }
  28. simpSquare = $0002;  { Simple button flag }
  29. simpDropSquare = $0003;  { Simple button flag }
  30. leftFlag = $0004;  { Scroll bar flag. }
  31. rightFlag = $0008;  { Scroll bar flag. }
  32. dirScroll = $0010;  { Scroll bar flag. }
  33. horScroll = $0010;  { Scroll bar flag. }
  34. family = $007F;  { Mask for radio button family number }
  35. ctlInVis = $0080;  { invisible mask for any type of control  }
  36. fCallWindowMgr = $0001;  { Control Template flag value }
  37. fSubstituteText = $0002;
  38. fSubTextType = $0001;
  39. inListBox = $88;
  40. fBlastText = $0004; { static text control }
  41. fTextCanDim = $0008; { static text control }
  42. fNoTrackIcon = $0008; { make icon button play dead }
  43.  
  44. { CtlProc Codes }
  45. simpleProc = $00000000;
  46. checkProc = $02000000;
  47. radioProc = $04000000;
  48. scrollProc = $06000000;
  49. growProc = $08000000;
  50.  
  51. { DefProc Commands }
  52. drawCtl = $0000;  { Draw control command. }
  53. calcCRect = $0001;  { Compute drag RECT command. }
  54. testCtl = $0002;  { Hit test command. }
  55. initCtl = $0003;  { Initialize command. }
  56. dispCtl = $0004;  { Dispose command. }
  57. posCtl = $0005;  { Move indicator command. }
  58. thumbCtl = $0006;  { Compute drag parameters command. }
  59. dragCtl = $0007;  { Drag command. }
  60. autoTrack = $0008;  { Action command. }
  61. newValue = $0009;  { Set new value command. }
  62. setParams = $000A;  { Set new parameters command. }
  63. moveCtl = $000B;  { Move command. }
  64. recSize = $000C;  { Return record size command. }
  65. ctlHandleEvent = $000D;  { Handle a keystroke or menu selection }
  66. ctlChangeTarget = $000E;  { Issued when control's target status has changed }
  67. ctlChangeBounds = $000F;  { Issued when control's boundary rectangle has changed }
  68. ctlWindChangeSize = $0010;  { Window has been grown or zoomed }
  69. ctlHandleTab = $0011;  { Control has been tabbed to }
  70. ctlNotifyMultiPart = $0012;  { A multipart control has been hidden, drawn or shown }
  71. ctlWinStateChange = $0013;  { Window state has changed }
  72.  
  73. { hiliteState Codes }
  74. noHilite = $0000;  { Param to HiliteControl }
  75. inactiveHilite = $00FF;  { Param to HiliteControl }
  76.  
  77. { PartCode Numbers }
  78. noPart = $0000;
  79. simpleButton = $0002;
  80. checkBox = $0003;
  81. radioButton = $0004;
  82. upArrow = $0005;
  83. downArrow = $0006;
  84. pageUp = $0007;
  85. pageDown = $0008;
  86. growBox = $000A;
  87. thumb = $0081;
  88.  
  89. { moreFlags Codes }
  90. fCtlTarget = $8000;  { is current target of typing commands }
  91. fCtlCanBeTarget = $4000;  { can be made the target control }
  92. fCtlWantEvent = $2000;  { control can be called view SendEventToCtl }
  93. fCtlWantsEvent = $2000;  { control can be called view SendEventToCtl }
  94. fCtlWantEvents = $2000;  { control can be called view SendEventToCtl }
  95. fCtlWantsEvents = $2000;  { control can be called view SendEventToCtl }
  96. fCtlProcRefNotPtr = $1000;  { set = ID of defproc, clear = pointer to defproc }
  97. fCtlTellAboutSize = $0800;  { set if ctl needs notification when size of owning window changes }
  98. fCtlIsMultiPart = $0400;  { set if ctl needs notification to be hidden }
  99. fMenuDefIsText = $0004;
  100. fDrawIconInResult = $0020;
  101. fDrawPopDownIcon = $0080;
  102. colorDescriptor = $000C;  { indicates type of reference in colorRef }
  103. styleDescriptor = $0003;  { indicates type of reference in styleRef }
  104.  
  105. { Ctl Verbs }
  106. titleIsPtr = $00;
  107. titleIsHandle = $01;
  108. titleIsResource = $02;
  109. colorTableIsPtr = $00;
  110. colorTableIsHandle = $04;
  111. colorTableIsResource = $08;
  112. ctlHideCtl = $12;
  113.  
  114. { InputVerb Codes }
  115. singlePtr = $0000;
  116. singleHandle = $0001;
  117. singleResource = $0002;
  118. ptrToPtr = $0003;
  119. ptrToHandle = $0004;
  120. ptrToResource = $0005;
  121. handleToPtr = $0006;
  122. handleToHandle = $0007;
  123. handleToResource = $0008;
  124. resourceToResource = $0009;
  125.  
  126. { ProcRefs }
  127. simpleButtonControl = $80000000;
  128. checkControl = $82000000;
  129. radioControl = $84000000;
  130. scrollBarControl = $86000000;
  131. growControl = $88000000;
  132. statTextControl = $81000000;
  133. editLineControl = $83000000;
  134. editTextControl = $85000000;
  135. popUpControl = $87000000;
  136. listControl = $89000000;
  137. pictureControl = $8D000000;
  138. iconButtonControl = $87FF0001;
  139. thermometerControl = $87FF0002;
  140. rectangleControl = $87FF0003;
  141.  
  142.  
  143. { Error Codes }
  144. wmNotStartedUp = $1001;  { Window manager was not initialized }
  145. cmNotInitialized = $1002;  { Control manager was not initialized }
  146. noCtlInList = $1003;  { Control not in window list }
  147. noCtlError = $1004;  { no controls in window }
  148. noSuperCtlError = $1005;  { no super controls in window }
  149. noCtlTargetError = $1006;  { no target super control }
  150. notSuperCtlError = $1007;  { action can only be done on super control }
  151. canNotBeTargetError = $1008;  { conrol cannot be made target }
  152. noSuchIDError = $1009;  { specified ID cannot be found }
  153. tooFewParmsError = $100A;  { not enough params specified }
  154. noCtlToBeTargetError = $100B;  { NextCtl call, no ctl could be target }
  155. noFrontWindowError = $100C;  { there is no front window }
  156.  
  157. { displayMode flags }
  158. selectedIcon = $0001;
  159. openIcon = $0002;
  160. offline = $0004;
  161.  
  162. { listType values }
  163. fListString = $0001;
  164. fListSelect = $0002;
  165. fListScrollBar = $0004;
  166.  
  167. { PopUp control flag values }
  168. fRightJustifyResult = $0001;
  169. fRightJustifyTitle = $0002;
  170. fInWindowOnly = $0004;
  171. fDontDrawResult = $0008;
  172. fDontDrawTitle = $0010;
  173. fDontHiliteTitle = $0020;
  174. fType2PopUp = $0040;
  175.  
  176. TYPE
  177. {$IFC UNDEFINED WindowPtr }
  178. WindowPtr = GrafPortPtr ;
  179. {$SETC WindowPtr := 0 }
  180. {$ENDC}
  181.  
  182.  
  183. BarColorsHndl = ^BarColorsPtr;
  184. BarColorsPtr = ^BarColors;
  185. BarColors = RECORD
  186.     barOutline : Integer; { color for outlining bar, arrows, and thumb }
  187.     barNorArrow : Integer; { color of arrows when not highlighted }
  188.     barSelArrow : Integer; { color of arrows when highlighted }
  189.     barArrowBack : Integer; { color of arrow box's background }
  190.     barNorThumb : Integer; { color of thumb's background when not highlighted }
  191.     barSelThumb : Integer; { color of thumb's background when highlighted }
  192.     barPageRgn : Integer; { color and pattern page region: high byte - 1= dither, 0 = solid }
  193.     barInactive : Integer; { color of scroll bar's interior when inactive }
  194. END;
  195.  
  196. BoxColorsHndl = ^BoxColorsPtr;
  197. BoxColorsPtr = ^BoxColors;
  198. BoxColors = RECORD
  199.     boxReserved : Integer; { reserved }
  200.     boxNor : Integer; { color of box when not checked }
  201.     boxSel : Integer; { color of box when checked }
  202.     boxTitle : Integer; { color of check box's title }
  203. END;
  204.  
  205. BttnColorsHndl = ^BttnColorsPtr;
  206. BttnColorsPtr = ^BttnColors;
  207. BttnColors = RECORD
  208.     bttnOutline : Integer; { color of outline }
  209.     bttnNorBack : Integer; { color of background when not selected }
  210.     bttnSelBack : Integer; { color of background when selected }
  211.     bttnNorText : Integer; { color of title's text when not selected }
  212.     bttnSelText : Integer; { color of title's text when selected }
  213. END;
  214.  
  215. CtlRecHndlPtr = ^CtlRecHndl;
  216. CtlRecHndl = ^CtlRecPtr;
  217. CtlRecPtr = ^CtlRec;
  218. CtlRec = PACKED RECORD
  219.     ctlNext : CtlRecHndl; { Handle of next control. }
  220.     ctlOwner : WindowPtr; { Pointer to control's window. }
  221.     ctlRect : Rect; { Enclosing rectangle. }
  222.     ctlFlag : Byte; { Bit flags. }
  223.     ctlHilite : Byte; { Highlighted part. }
  224.     ctlValue : Integer; { Control's value. }
  225.     ctlProc : LongProcPtr; { Control's definition procedure. }
  226.     ctlAction : LongProcPtr; { Control's action procedure. }
  227.     ctlData : Longint; { Reserved for CtrlProc's use. }
  228.     ctlRefCon : Longint; { Reserved for application's use. }
  229.     ctlColor : Ptr; { Pointer to appropriate color table. }
  230.     ctlReserved : PACKED ARRAY[1..16] OF Byte; { Reserved for future expansion }
  231.     ctlID : Longint;
  232.     ctlMoreFlags : Integer;
  233.     ctlVersion : Integer;
  234. END;
  235.  
  236. LimitBlkHndl = ^LimitBlkPtr;
  237. LimitBlkPtr = ^LimitBlk;
  238. LimitBlk = RECORD
  239.     boundRect : Rect; { Drag bounds. }
  240.     slopRect : Rect; { Cursor bounds. }
  241.     axisParam : Integer; { Movement constrains. }
  242.     dragPatt : Ptr; { Pointer to 32 byte Pattern for drag outline. }
  243. END;
  244.  
  245. RadioColorsHndl = ^RadioColorsPtr;
  246. RadioColorsPtr = ^RadioColors;
  247. RadioColors = RECORD
  248.     radReserved : Integer; { reserved }
  249.     radNor : Integer; { color of radio button when off }
  250.     radSel : Integer; { color of radio button when on }
  251.     radTitle : Integer; { color of radio button's title text }
  252. END;
  253.  
  254. KeystrokeRec = PACKED RECORD
  255.     key1 : Byte;
  256.     key2 : Byte;
  257.     keyModifiers : Integer;
  258.     keyCareBits : Integer;
  259. END;
  260.  
  261. ControlTemplate = RECORD
  262.     pCount : Integer;
  263.     ID : Longint;
  264.     rect : Rect;
  265.     procRef : Longint;
  266.     flag : Integer;
  267.     moreFlags : Integer;
  268.     refCon : Longint;
  269. END;
  270.  
  271. SimpleButtonTemplate = RECORD
  272.     ctlTemplate : ControlTemplate;
  273.     titleRef : Ref;
  274.     colorTableRef : Ref;
  275.     keyEquivalent : KeystrokeRec;
  276. END;
  277.  
  278. CheckBoxTemplate = RECORD
  279.     ctlTemplate : ControlTemplate;
  280.     titleRef : Ref;
  281.     initalValue : Integer;
  282.     colorTableRef : Ref;
  283.     keyEquivalent : KeystrokeRec;
  284. END;
  285.  
  286. IconButtonTemplate = RECORD
  287.     ctlTemplate : ControlTemplate;
  288.     iconRef : Ref;
  289.     titleRef : Ref;
  290.     colorTableRef : Ref;
  291.     displayMode : Integer;
  292.     keyEquivalent : KeystrokeRec;
  293. END;
  294.  
  295. LineEditTemplate = RECORD
  296.     ctlTemplate : ControlTemplate;
  297.     maxSize : Integer;
  298.     defaultRef : Ref;
  299.     passwordChar: Integer;
  300. END;
  301.  
  302. ListTemplate = RECORD
  303.     ctlTemplate : ControlTemplate;
  304.     listSize : Integer;
  305.     listView : Integer;
  306.     listType : Integer;
  307.     listStart : Integer;
  308.     listDraw : ProcPtr;
  309.     listMemHeight : Integer;
  310.     listMemSize : Integer;
  311.     listRef : Ref;
  312.     colorTableRef : Ref;
  313. END;
  314.  
  315. PictureTemplate = RECORD
  316.     ctlTemplate : ControlTemplate;
  317.     pictureRef : Ref;
  318. END;
  319.  
  320. PopupTemplate = RECORD
  321.     ctlTemplate : ControlTemplate;
  322.     titleWidth : Integer;
  323.     menuRef : Ref;
  324.     initialValue : Integer;
  325.     colorTableRef : Ref;
  326. END;
  327.  
  328. RadioButtonTemplate = RECORD
  329.     ctlTemplate : ControlTemplate;
  330.     titleRef : Ref;
  331.     initalValue : Integer;
  332.     colorTableRef : Ref;
  333.     keyEquivalent : KeystrokeRec;
  334. END;
  335.  
  336. RectangleTemplate = RECORD
  337.     ctlTemplate: ControlTemplate;
  338.     penHeight: integer;
  339.     penWidth: integer;
  340.     penMask: Mask;
  341.     penPattern: Pattern;
  342. END;
  343.  
  344. ScrollBarTemplate = RECORD
  345.     ctlTemplate : ControlTemplate;
  346.     maxSize : Integer;
  347.     viewSize : Integer;
  348.     initalValue : Integer;
  349.     colorTableRef : Ref;
  350. END;
  351.  
  352. SizeBoxTemplate = RECORD
  353.     ctlTemplate : ControlTemplate;
  354.     colorTableRef : Ref;
  355. END;
  356.  
  357. StaticTextTemplate = RECORD
  358.     ctlTemplate : ControlTemplate;
  359.     textRef : Ref;
  360.     textSize : Integer;
  361.     just : Integer;
  362. END;
  363.  
  364. TextEditTemplate = RECORD
  365.     ctlTemplate : ControlTemplate;
  366.     textFlags : Longint;
  367.     indentRect : Rect;
  368.     vertBar : CtlRecHndl;
  369.     vertAmount : Integer;
  370.     horzBar : CtlRecHndl;
  371.     horzAmount : Integer;
  372.     styleRef : Ref;
  373.     textDescriptor : Integer;
  374.     textRef : Ref;
  375.     textLength : Longint;
  376.     maxChars : Longint;
  377.     maxLines : Longint;
  378.     maxCharsPerLine : Integer;
  379.     maxHeight : Integer;
  380.     colorRef : Ref;
  381.     drawMode : Integer;
  382.     filterProcPtr : ProcPtr;
  383. END;
  384.  
  385. ThermometerTemplate = RECORD
  386.     ctlTemplate: ControlTemplate;
  387.     value: integer;
  388.     data: integer;
  389.     colorTableRef: Ref;
  390. END;
  391.  
  392. FUNCTION  CallCtlDefProc ( ctlHandle:CtlRecHndl; ctlMessage:Integer; ctlParam:Longint) : Longint ;
  393. FUNCTION  CMLoadResource ( resourceType:Integer; resourceID:Longint) : Handle ;
  394. PROCEDURE CMReleaseResource ( resourceType:Integer; resourceID:Longint)  ;
  395. PROCEDURE CtlBootInit   ;
  396. PROCEDURE CtlNewRes   ;
  397. PROCEDURE CtlReset   ;
  398. PROCEDURE CtlShutDown   ;
  399. PROCEDURE CtlStartUp ( userID:Integer; dPageAddr:Integer)  ;
  400. FUNCTION  CtlStatus  : Boolean ;
  401. FUNCTION  CtlVersion  : Integer ;
  402. PROCEDURE DisposeControl ( theControlHandle:CtlRecHndl)  ;
  403. PROCEDURE DragControl ( startX:Integer; startY:Integer; limitRectPtr:Rect; slopRectPtr:Rect; dragFlag:Integer; theControlHandle:CtlRecHndl)  ;
  404. FUNCTION  DragRect ( actionProcPtr:VoidProcPtr; dragPatternPtr:Pattern; startX:Integer; startY:Integer;VAR dragRectPtr:Rect; limitRectPtr:Rect; slopRectPtr:Rect; dragFlag:Integer) : Point ;
  405. PROCEDURE DrawControls ( theWindowPtr:WindowPtr)  ;
  406. PROCEDURE DrawOneCtl ( theControlHandle:CtlRecHndl)  ;
  407. PROCEDURE EraseControl ( theControlHandle:CtlRecHndl)  ;
  408. FUNCTION  FindControl (VAR foundCtl:CtlRecHndl; pointX:Integer; pointY:Integer; theWindowPtr:WindowPtr) : Integer ;
  409. FUNCTION  FindTargetCtl  : CtlRecHndl ;
  410. PROCEDURE FutzCtls   ;
  411. FUNCTION  GetCtlAction ( theControlHandle:CtlRecHndl) : LongProcPtr ;
  412. FUNCTION  GetCtlDPage  : Integer ;
  413. FUNCTION  GetCtlHandleFromID ( ctlWindowPtr:WindowPtr; ctlID:Longint) : CtlRecHndl ;
  414. FUNCTION  GetCtlID ( ctlHandle:CtlRecHndl) : Longint ;
  415. FUNCTION  GetCtlMoreFlags ( ctlHandle:CtlRecHndl) : Integer ;
  416. FUNCTION  GetCtlParamPtr  : Ptr ;
  417. FUNCTION  GetCtlParams ( theControlHandle:CtlRecHndl) : Longint ;
  418. FUNCTION  GetCtlRefCon ( theControlHandle:CtlRecHndl) : Longint ;
  419. FUNCTION  GetCtlTitle ( theControlHandle:CtlRecHndl) : Ptr ;
  420. FUNCTION  GetCtlValue ( theControlHandle:CtlRecHndl) : Integer ;
  421. FUNCTION  GrowSize  : Longint ;
  422. PROCEDURE HideControl ( theControlHandle:CtlRecHndl)  ;
  423. PROCEDURE HiliteControl ( hiliteState:Integer; theControlHandle:CtlRecHndl)  ;
  424. PROCEDURE InvalCtls ( ctlWindowPtr:WindowPtr)  ;
  425. PROCEDURE KillControls ( theWindowPtr:WindowPtr)  ;
  426. FUNCTION  MakeNextCtlTarget  : CtlRecHndl ;
  427. PROCEDURE MakeThisCtlTarget ( ctlToBeTarget:CtlRecHndl)  ;
  428. PROCEDURE MoveControl ( newX:Integer; newY:Integer; theControlHandle:CtlRecHndl)  ;
  429. FUNCTION  NewControl ( theWindowPtr:WindowPtr; boundsRectPtr:Rect; titlePtr:Ptr; flag:Integer; value :Integer; param1:Integer; param2:Integer; defProcPtr:LongProcPtr; refCon:Longint; newColorTablePtr:ColorTablePtr) : CtlRecHndl ;
  430. FUNCTION  NewControl2 ( ownerPtr:WindowPtr; inputDesc:RefDescriptor; inputRef:Ref) : CtlRecHndl ;
  431. PROCEDURE NotifyControls ( notifyMask:Integer; message:Integer; notifyParam:Longint; window:WindowPtr)  ;
  432. PROCEDURE NotifyCtls ( moreFlagsMask:Integer; ctlMessage:Integer; ctlParam:Longint; theWindowPtr:WindowPtr)  ;
  433. FUNCTION  SendEventToCtl ( targetOnlyFlag:Integer; ctlWindowPtr:WindowPtr; eTaskRecPtr:Ptr) : Boolean ;
  434. PROCEDURE SetCtlAction ( newActionPtr:LongProcPtr; theControlHandle:CtlRecHndl)  ;
  435. FUNCTION  SetCtlIcons ( newFontHandle:FontHndl) : FontHndl ;
  436. PROCEDURE SetCtlID ( newID:Longint; ctlHandle:CtlRecHndl)  ;
  437. PROCEDURE SetCtlMoreFlags ( newMoreFlags:Integer; ctlHandle:CtlRecHndl)  ;
  438. PROCEDURE SetCtlParamPtr ( SubArrayPtr:Ptr)  ;
  439. PROCEDURE SetCtlParams ( param2:Integer; param1:Integer; theControlHandle:CtlRecHndl)  ;
  440. PROCEDURE SetCtlRefCon ( newRefCon:Longint; theControlHandle:CtlRecHndl)  ;
  441. PROCEDURE SetCtlTitle ( title:Str255; theControlHandle:CtlRecHndl)  ;
  442. PROCEDURE SetCtlValue ( curValue:Integer; theControlHandle:CtlRecHndl)  ;
  443. PROCEDURE ShowControl ( theControlHandle:CtlRecHndl)  ;
  444. FUNCTION  TestControl ( pointX:Integer; pointY:Integer; theControlHandle:CtlRecHndl) : Integer ;
  445. FUNCTION  TrackControl ( startX:Integer; startY:Integer; actionProcPtr:LongProcPtr; theControlHndl:CtlRecHndl) : Integer ;
  446.  
  447. FUNCTION FindRadioButton(theWindow:WindowPtr; theFamily:integer): integer;
  448. PROCEDURE SetLETextByID(theWindow:WindowPtr; theID:longint; s:StringPtr);
  449. PROCEDURE GetLETextByID(theWindow:WindowPtr; theID:longint; s:StringPtr);
  450.  
  451. IMPLEMENTATION
  452.  
  453. END.
  454.